home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
sortc.arc
/
FGETSS.C
< prev
next >
Wrap
Text File
|
1987-06-17
|
474b
|
26 lines
/*
* fgetss() is like fgets() except that the terminating newline
* is removed.
*/
#include <stdio.h>
char *fgetss(s, n, iop)
char *s;
register FILE *iop;
{
register c;
register char *cs;
cs = s;
while ((c = getc(iop)) >= 0 && --n > 0)
{
*cs++ = c;
if (c == '\n')
break;
}
if (c < 0 && cs == s)
return(NULL);
cs[-1] = '\0'; /* Overwrite newline as null */
return(s);
}